<?php

/**
*
* @author  :  Dennis T Kaplan
*             URL: http://linux.PzzAzz.net
*        
* @version :  1.0
* Date     :  June 17, 2007
* Function : getip
* Purpose  : Get IP Address
*
* @access	public
* @return	string
**/ 

function getip() {
    if (getenv('HTTP_CLIENT_IP')) {
        $IP = getenv('HTTP_CLIENT_IP');
    }
    elseif (getenv('HTTP_X_FORWARDED_FOR')) {
        $IP = getenv('HTTP_X_FORWARDED_FOR');
    }
    elseif (getenv('HTTP_X_FORWARDED')) {
        $IP = getenv('HTTP_X_FORWARDED');
    }
    elseif (getenv('HTTP_FORWARDED_FOR')) {
        $IP = getenv('HTTP_FORWARDED_FOR');
    }
    elseif (getenv('HTTP_FORWARDED')) {
        $IP = getenv('HTTP_FORWARDED');
    }
    else {
        $IP = $_SERVER['REMOTE_ADDR'];
    }
    
    if (strstr($IP, ', ')) {
        $ips = explode(', ', $IP);
        $IP = $ips[0];
    }
    return($IP);
}
?>